package com.lbw.Server.ratelimit.provider;


import com.lbw.Server.ratelimit.RateLimit;
import com.lbw.Server.ratelimit.impl.TokenBucketRateLimitImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lbwxxc
 * @date 2025/2/23 10:39
 * @description: TODO
 */
public class RateLimitProvider {

    private Map<String, RateLimit> rateLimitMap = new HashMap<>();

    public RateLimit getRateLimit(String interfaceName) {
        if (!rateLimitMap.containsKey(interfaceName)) {
            TokenBucketRateLimitImpl rateLimit = new TokenBucketRateLimitImpl(100, 10);
            rateLimitMap.put(interfaceName, rateLimit);
            return rateLimit;
        }
        return rateLimitMap.get(interfaceName);
    }
}
